import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 设备保养配置信息 */
export interface EquipmentKeepConfig {
  id: number // id
  configType?: number // 配置类型1按分类2按设备
  targetId?: number // 根据配置类型，可能是分类ID或设备ID
  itemId?: string // 保养项ID
}

// 设备保养配置 API
export const EquipmentKeepConfigApi = {
  // 查询设备保养配置分页
  getEquipmentKeepConfigPage: async (params: any) => {
    return await request.get({ url: `/business/equipment-keep-config/page`, params })
  },

  // 查询设备保养配置详情
  getEquipmentKeepConfig: async (id: number) => {
    return await request.get({ url: `/business/equipment-keep-config/get?id=` + id })
  },

  // 新增设备保养配置
  createEquipmentKeepConfig: async (data: EquipmentKeepConfig) => {
    return await request.post({ url: `/business/equipment-keep-config/create`, data })
  },

  // 批量配置
  batchEquipmentKeepConfig: async (data) => {
    // 改为 data 更清晰
    return await request.post({
      url: `/business/equipment-keep-config/batchConfig`,
      data // 明确作为请求体发送
    })
  },

  // 查询设备保养配置详情
  handleJob: async () => {
    return await request.get({ url: `/business/equipment-keep-config/handleJob` })
  },

  // 修改设备保养配置
  updateEquipmentKeepConfig: async (data: EquipmentKeepConfig) => {
    return await request.put({ url: `/business/equipment-keep-config/update`, data })
  },

  // 删除设备保养配置
  deleteEquipmentKeepConfig: async (id: number) => {
    return await request.delete({ url: `/business/equipment-keep-config/delete?id=` + id })
  },

  /** 批量删除设备保养配置 */
  deleteEquipmentKeepConfigList: async (ids: number[]) => {
    return await request.delete({
      url: `/business/equipment-keep-config/delete-list?ids=${ids.join(',')}`
    })
  },

  // 导出设备保养配置 Excel
  exportEquipmentKeepConfig: async (params) => {
    return await request.download({ url: `/business/equipment-keep-config/export-excel`, params })
  },

  //维护模块的====================================================

  getEquipmentKeepConfigPageDamage: async (params: any) => {
    return await request.get({ url: `/Damage/equipment-keep-config/page`, params })
  },

  // 查询设备保养配置详情
  getEquipmentKeepConfigDamage: async (id: number) => {
    return await request.get({ url: `/Damage/equipment-keep-config/get?id=` + id })
  },

  // 新增设备保养配置
  createEquipmentKeepConfigDamage: async (data: EquipmentKeepConfig) => {
    return await request.post({ url: `/Damage/equipment-keep-config/create`, data })
  },

  // 批量配置
  batchEquipmentKeepConfigDamage: async (data) => {
    // 改为 data 更清晰
    return await request.post({
      url: `/Damage/equipment-keep-config/batchConfig`,
      data // 明确作为请求体发送
    })
  },

  // 查询设备保养配置详情
  handleJobDamage: async () => {
    return await request.get({ url: `/Damage/equipment-keep-config/handleJob` })
  },

  // 修改设备保养配置
  updateEquipmentKeepConfigDamage: async (data: EquipmentKeepConfig) => {
    return await request.put({ url: `/Damage/equipment-keep-config/update`, data })
  },

  // 删除设备保养配置
  deleteEquipmentKeepConfigDamage: async (id: number) => {
    return await request.delete({ url: `/Damage/equipment-keep-config/delete?id=` + id })
  },

  /** 批量删除设备保养配置 */
  deleteEquipmentKeepConfigListDamage: async (ids: number[]) => {
    return await request.delete({
      url: `/Damage/equipment-keep-config/delete-list?ids=${ids.join(',')}`
    })
  },

  // 导出设备保养配置 Excel
  exportEquipmentKeepConfigDamage: async (params) => {
    return await request.download({ url: `/Damage/equipment-keep-config/export-excel`, params })
  }
}
